package org.amphiprion.whohavethekids.query.view.builder;

import java.util.Date;

import org.amphiprion.kidcalendar.entity.Configuration;
import org.amphiprion.whohavethekids.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;

public class DateInput implements QueryInputBuilder {
	// private List<CheckBox> chks = new ArrayList<CheckBox>();
	private DatePicker datePicker;

	@Override
	public void build(Context context, ViewGroup root, Configuration configuration) {
		LayoutInflater inflater = LayoutInflater.from(context);
		View v = inflater.inflate(R.layout.query_input_date, root);
		datePicker = (DatePicker) v.findViewById(R.id.dateInput);
	}

	@Override
	public Object getInput() {
		Date selectedDate = new Date(datePicker.getYear() - 1900, datePicker.getMonth(), datePicker.getDayOfMonth());
		// System.out.println(">>> DAate:" + selectedDate);
		return selectedDate;
	}

	@Override
	public boolean isInputValid() {
		// at least one kid selected
		// for (CheckBox chk : chks) {
		// if (chk.isChecked()) {
		// return true;
		// }
		// }
		return true;
	}
}
